CC=g++
SDL_LIBS=`sdl2-config --libs` -lSDL2_image -lSDL2_ttf
SDL_INCLUDD=`sdl2-config --cflags`

CFLAGS=-Wall -ggdb -std=c++11 $(SDL_INCLUDD) -I/usr/local/include
## 包含头文件
LDFLAGS=$(SDL_LIBS) -L/usr/local/lib
## 链接库

TARGET=graphff

SOURCE=main.cc event.cc window.cc domain_track_interval.cc  interval.cc  bool_interval.cc mymath.cc font.cc formula_sytanmic.cc

OBJ=$(join $(addsuffix obj/, $(dir $(SOURCE))), $(notdir $(SOURCE:.cc=.o)))
DEPENDS=$(join $(addsuffix .dep/, $(dir $(SOURCE))), $(notdir $(SOURCE:.cc=.d)))

.PHONY:all clean
all:$(TARGET)
	@true

clean:
	@-rm -rf $(TARGET) $(OBJ) $(DEPENDS)
	@-rm -rf obj .dep

$(TARGET):$(OBJ)
	@echo "--- Linking target $@"
	@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

obj/%.o:%.cc
	@mkdir -p $(dir $@)
	@echo "--- Compling $<"
	@$(CC) $(CFLAGS) -c $< -o $@

.dep/%.d:%.cc
	@mkdir -p $(dir $@)
	@echo "--- Building dependencies file for $*.o"
	@$(CC) $(CFLAGS) -M $< -o $@ 

-include $(DEPENDS)
